// pages/editInfo/editInfo.js
Page({

  /**
   * Page initial data
   */
  data: {
    userInfo: {},
    userName:"",
    phone:0,
    address:"",
  },

  /**
   * Lifecycle function--Called when page load
   */
  onLoad: function (options) {
    
   
    
  },

getUserInfo: function(e) {
  this.setData({
    userName: e.detail.value,
  })
},

getPhone:function(e) {
  this.setData({
    phone: e.detail.value,
  })
},

  getAddress:function(e) {
    this.setData({
      address: e.detail.value,
    })
  },

  submitInfo: function() {
    var that = this;
    let userInfo = {};
    userInfo = wx.getStorageSync('userInfo');
    userInfo.userName = that.data.userName;
    userInfo.phone = that.data.phone;
    userInfo.address = that.data.address;

    wx.setStorageSync('userInfo', userInfo);

    wx.navigateBack({
      delta: 1
    })
  },

  // 取消
  cancel: function() {
    wx.navigateBack({
      delta: 1
    })
  },

  /**
   * Lifecycle function--Called when page is initially rendered
   */
  onReady: function () {

  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow: function () {
    var that = this;
        let userInfo = {};
        userInfo = wx.getStorageSync('userInfo');

        that.setData({
          userName: userInfo.userName,
          phone: userInfo.phone,
          address: userInfo.address,
        });
  },

  /**
   * Lifecycle function--Called when page hide
   */
  onHide: function () {

  },

  /**
   * Lifecycle function--Called when page unload
   */
  onUnload: function () {

  },

  /**
   * Page event handler function--Called when user drop down
   */
  onPullDownRefresh: function () {

  },

  /**
   * Called when page reach bottom
   */
  onReachBottom: function () {

  },

  /**
   * Called when user click on the top right corner to share
   */
  onShareAppMessage: function () {

  }
})